<script setup lang="ts">
import PreviewPage from "../PreviewPage.vue";

const headerHeight = "30px";

const startIdx = location.search.indexOf("path=")
let endIdx = location.search.indexOf("&", startIdx)
if (endIdx == -1) {
  endIdx = location.search.length;
}
const path = decodeURIComponent(location.search.substring(startIdx + 5, endIdx))

function openItem() {
  window.api.openItem(path);
}
</script>

<template>
  <div class="titlebar" :style="{ height: headerHeight }">
    <div>预览</div>
    <div class="btn default-btn" title="使用电脑默认软件打开" @click="openItem"></div>
  </div>
  <div class="content-box" :style="{ height: `calc(100% - ${headerHeight})` }">
    <PreviewPage :path="path"></PreviewPage>
  </div>
</template>

<style scoped lang="less">
.titlebar {
  .default-btn {
    right: 45px;
    background-image: url(../../assets/images/mrrj.svg);
  }
}

</style>
